package org.glow.changgou.content.controller;

import org.glow.changgou.content.pojo.Content;
import org.glow.changgou.content.service.ContentService;
import org.glow.changgou.entity.Result;
import org.glow.changgou.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Glow
 * @Date 2022-09-26 19:41:45
 * @Description
 * @Version 1.0
 */
@RestController
public class ContentController {
    @Autowired
    private ContentService contentService;
    /***
     * 根据categoryId查询广告集合
     */
    @GetMapping(value = "/list/category/{id}")
    public Result<List<Content>> findByCategory(@PathVariable Long id){
        //根据分类ID查询广告集合
        List<Content> contents = contentService.findByCategory(id);
        return new Result<List<Content>>(true, StatusCode.OK,"查询成功！",contents);
    }
}
